"""
编程题
(1).定义员工类Employee,包含私有属性(姓名和月工资),以及计算年工资get_annual的方法
(2).普通员工(Worker)和经理(Manager)继承员工类,经理多了奖金bonus属性和管理manage方法,普通员工
类多了work方法,普通员工和经理要求根据需要重写get_annual方法
(3).编写函数 show_emp_annual(e:Employee),实现获取任何员工对象的年工资
(4).编写函数working(e:Employee),如果是普通员工,则调用work方法,如果是经理,则调用manage方法
"""


class Employee:
    __name = None
    __salary = None

    # 使用构造方法进行初始化
    def __init__(self, name, salary):
        self.__name = name
        self.__salary = salary

    # 提供set和get方法，用作获取父类的数据
    def setName(self, name):
        self.__name = name

    def getName(self):
        return self.__name

    def setSalary(self, salary):
        self.__salary = salary

    def getSalary(self):
        return self.__salary

    def get_annual(self):
        return self.__salary * 12


class Worker(Employee):
    def work(self):
        print(f"员工{self.getName()}正在工作...")


class Manager(Employee):
    __bonus = None

    def __init__(self, name, salary, bonus):
        super().__init__(name, salary)
        self.__bonus = bonus

    def setBonus(self, bonus):
        self.__bonus = bonus

    def getBonus(self):
        return self.__bonus

    def manage(self):
        print(f"管理员{self.getName()}正在进行管理...")

    def get_annual(self):
        return super().get_annual() + self.__bonus

#获取任何对象的年工资
def show_emp_annual(e: Employee):
    return e.get_annual()

# working(e:Employee)
def working(e:Employee):
    if isinstance(e , Worker):
        e.work()
    elif isinstance(e , Manager):
        e.manage()
    else:
        print("参数错误")

#员工
worker1 = Worker("樊振东" , 10000)
working(worker1)
print(show_emp_annual(worker1))
#领导
manager1 = Manager("秦志戬" , 20000 , 100000)
working(manager1)
print(show_emp_annual(manager1))


